/*
 * Lenovo Group
 * Copyright (c) 2015-2016 All Rights Reserved.
 * Project Name: lmrp-android app
 * Create Time: 16-2-16 下午6:44
 */

package com.lenovo.mso2o.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.lenovo.framework.base.ActionBarFragment;
import com.lenovo.framework.view.ContentLoaderView;
import com.lenovo.mso2o.R;
import com.lenovo.mso2o.conf.MSConstants;
import com.lenovo.mso2o.entity.OrderListRequest;

import butterknife.Bind;

/**
 * Created by hippo on 12/20/15.
 */
public class OrderReceivingFragment extends ActionBarFragment implements ContentLoaderView.OnRefreshListener{
    //控件绑定
    @Bind(R.id.frame_orderContainner)
    FrameLayout frameContainner;

    //变量声明
    private OrderListRequest params = new OrderListRequest();
    private OrderListFragment orderListFragment;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        params.setStatus(MSConstants.ListParamConstants.listType_receive);
        params.setSort(MSConstants.ListParamConstants.orderBy_default);
        params.setLimit(MSConstants.ListParamConstants.pageSize_default);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        initFragment();
        return view;
    }

    /**
     * 初始化orderFragment
     *
     * @return
     */
    public void initFragment() {
        orderListFragment = (OrderListFragment) OrderListFragment.newInstance(getActivity(), MSConstants.FragmentType.FRAGMENT_RECEIVEORDERS);
        getChildFragmentManager().beginTransaction().replace(R.id.frame_orderContainner, orderListFragment).commit();
        orderListFragment.initParams(params, false);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    }

    @Override
    public int provideContentRes() {
        return R.layout.fragment_receive_order;
    }

    @Override
    protected void onFragmentInVisible(Bundle savedInstanceState) {

    }

    @Override
    protected void onFragmentVisible(Bundle savedInstanceState) {

    }

    @Override
    public int getActionBarRightResourceId() {
       // return R.drawable.icon_order_marker;
        return 0;
    }

    @Override
    public int getActionBarRight2ResourceId() {
        return 0;
    }

    @Override
    public void onActionBarRight2Click() {

    }

    @Override
    public void onActionBarRightClick() {

    }

    @Override
    public void onRefresh(boolean fromSwipe) {
        if(orderListFragment != null) {
            orderListFragment.onRefresh(fromSwipe);
        }
    }
}
